﻿@using MvcJqGrid
@{
    ViewBag.Title = "Menufacturer";
}
@section scripts
{
    <script type="text/javascript">
        function EditDeleteMenufacturer(cellvalue, options, rowobject) {
            return '<a onclick="return MenufacturerDetails(' + options.rowId + ')" href="#"><div class="ui-icon ui-icon-pencil" style="display:inline-block"></div></a>' +
                   '<a onclick="return DeleteMenufacturer(' + options.rowId + ')" href="#"><div class="ui-icon ui-icon-trash" style="display:inline-block"></div></a>';
        }

        function MenufacturerDetails(id) {
            var url = '@Url.Action("MenufacturerDetails", "Manufacturer")/?id=' + id;
            $("#dialogEdit").dialog({
                autoOpen: true,
                resizable: false,
                height: 400,
                show: { effect: 'drop', direction: "up" },
                width: 450,
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);
                }, close: function (event, ui) {
                    $(this).dialog('close');
                }
            });
        }
        function DeleteMenufacturer(id) {
            var url = '@Url.Action("DeleteMenufacturer", "Manufacturer")/?id=' + id;
            $("#dialogConfirm").dialog({
                autoOpen: true,
                resizable: false,
                height: 170,
                show: { effect: 'drop', direction: "up" },
                width: 350,
                modal: true,
                draggable: true,
                buttons: {
                    "OK": function () {
                        $(this).dialog("close");
                        window.location = url;
                    },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                }
            });
        }
    </script>
}

<div id="dialogEdit" title="Edit Menufacturer" style="display: none">
</div>

<div id="dialogConfirm" title="Delete Menufacturer" style="display: none">
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
        Are you sure to delete ?
    </p>
</div>

<a href="#" onclick="return MenufacturerDetails()">Add Category</a>
<br />

@*<table width="100%" height="170px" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all rfloat">
    <tr>
        <th colspan="4" class="ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix">Search Menufacturer
        </th>
    </tr>
    <tr>
        <th>Name:
        </th>
        <td>
            <input type="text" id="txtName" value="" class="inp-form" />
        </td>
        <th>Description:
        </th>
        <td>
            <input type="text" id="txtDescripton" value="" class="inp-form" />
        </td>
    </tr>
    <tr>
        <td></td>
        <td colspan="3">
            <input type="button" id="lnkSearch" class="form-submit" value="Search" onclick="reloadGrid(false);" />

        </td>
    </tr>
</table>*@
<div style="clear: both; height: 10px;">
</div>

@(Html.Grid("MenufacturerGrid")
.SetRequestType(MvcJqGrid.Enums.RequestType.Post)
.SetJsonReader(new MvcJqGrid.DataReaders.JsonReader { Id = "ID", RepeatItems =false})
.SetShowAllSortIcons(true)
.SetAutoWidth(true)
.SetCaption("Menefacturer")
.AddColumn(new Column("Name"))
.AddColumn(new Column("Phone").SetAlign(Align.Right))
.AddColumn(new Column("Email"))
.AddColumn(new Column("Address"))
.AddColumn(new Column("City"))
.AddColumn(new Column("Country"))
.AddColumn(new Column("Action").SetCustomFormatter("EditDeleteMenufacturer").SetSortable(false).SetWidth(50).SetAlign(Align.Right))
.SetUrl(Url.Action("MenufacturerGrid","Manufacturer"))
.SetRowNum(10)
.SetRowList(new[] {10,15,20,50})
.SetPager("pager")

)
